<?php

namespace Core\Controllers;

final class View {

    private static $objInstance;

    public $Paths;

    private $strControllerName;
    private $strActionName;

    function __construct ( $strControllerName, $strActionName ) {
        $this->Paths = \Core\Paths::getInstance();
        $this->strControllerName = $strControllerName;
        $this->strActionName = $strActionName;
    }

    /**
     * Gets an instance of itself.
     *
     * @return Core_Controllers_Front
     */
    public static function getInstance () {

        if ( !self::$objInstance instanceof self )
            self::$objInstance = new self;

        return self::$objInstance;

    }

    public function dispatch () {
        require_once $this->Paths->Views . $this->strControllerName . "/" . $this->strActionName . "View.php";
    }

    /**
     * Gets the contents of a file in the views directory.
     * 
     * @param string $strURI URI to the file below the views directory.
     * @return string The content of the file.
     */
    public function load ( $strFilename ) { // Rename to loadTemplate

        $resFile = fopen( $this->Paths->Views . $strFilename, "r" );
        $strContents = fread( $resFile, filesize( $this->Paths->Views . $strFilename ) );
        fclose( $resFile );

        return $strContents;

    }

    public function loadController ( $strControllerName ) { // rename to include
        
    }

}

?>